'use strict';
var even_group_calculate_average = function(collection){
    let arr1=new Array();
    for(let i=0;i<collection.length;i++){                  //选出第偶数个元素
        if((i+1)%2==0){
            arr1.push(collection[i]);
        }
    }
    let arr2=new Array();                                                  
    for(let i=0;i<arr1.length;i++){                     
        if(arr1[i]%2==0){
            arr2.push(arr1[i]);
        }
    }
    let result=new Array();               //没有偶数
    if(arr2.length==0){
        result.push(0);
    }
    else{
        let n=[0,0,0];
        let sum=[0,0,0];
        for(let i=0;i<arr2.length;i++){
            if(arr2[i]>=0&&arr2[i]<10){
                sum[0]=sum[0]+arr2[i]; 
                n[0]++;               
            }
            else if(arr2[i]>=10&&arr2[i]<100){
                sum[1]=sum[1]+arr2[i];
                n[1]++;
            }
            else{
                sum[2]=sum[2]+arr2[i];
                n[2]++;
            }
        }
        for(let i=0;i<3;i++){
            if(n[i]!=0){
                result.push(sum[i]/n[i]);
            }
        }
    }
    return result;
}
module.exports = even_group_calculate_average;
